package com.devbobcorn.misaka.blocks;

import java.util.function.ToIntFunction;

import com.devbobcorn.misaka.Misaka;

import net.minecraft.block.AbstractBlock;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
import net.minecraft.item.Items;
import net.minecraft.state.properties.BlockStateProperties;
import net.minecraftforge.fml.RegistryObject;
import net.minecraftforge.registries.DeferredRegister;
import net.minecraftforge.registries.ForgeRegistries;

public final class ModBlocks {
    public static final DeferredRegister<Block> BLOCKS = DeferredRegister.create(ForgeRegistries.BLOCKS, Misaka.MODID);

    public static final RegistryObject<Block> MISAKA_CAKE = BLOCKS.register("misaka_cake", () -> new MisakaCakeBlock(AbstractBlock.Properties.of(Material.CAKE).strength(0.5F).sound(SoundType.WOOL)));

    public static final RegistryObject<Block> CANDLE_MISAKA_CAKE = BLOCKS.register("candle_misaka_cake",() -> new CandleMisakaCakeBlock(AbstractBlock.Properties.copy(Blocks.CAKE).lightLevel(candleCakeEmission(3))));
    public static final RegistryObject<Block> WHITE_CANDLE_MISAKA_CAKE = BLOCKS.register("white_candle_misaka_cake",() -> new CandleMisakaCakeBlock(Items.WHITE_DYE, AbstractBlock.Properties.copy(CANDLE_MISAKA_CAKE.get())));
    public static final RegistryObject<Block> ORANGE_CANDLE_MISAKA_CAKE = BLOCKS.register("orange_candle_misaka_cake",() -> new CandleMisakaCakeBlock(Items.ORANGE_DYE, AbstractBlock.Properties.copy(CANDLE_MISAKA_CAKE.get())));
    public static final RegistryObject<Block> MAGENTA_CANDLE_MISAKA_CAKE = BLOCKS.register("magenta_candle_misaka_cake",() -> new CandleMisakaCakeBlock(Items.MAGENTA_DYE, AbstractBlock.Properties.copy(CANDLE_MISAKA_CAKE.get())));
    public static final RegistryObject<Block> LIGHT_BLUE_CANDLE_MISAKA_CAKE = BLOCKS.register("light_blue_candle_misaka_cake",() -> new CandleMisakaCakeBlock(Items.LIGHT_BLUE_DYE, AbstractBlock.Properties.copy(CANDLE_MISAKA_CAKE.get())));
    public static final RegistryObject<Block> YELLOW_CANDLE_MISAKA_CAKE = BLOCKS.register("yellow_candle_misaka_cake",() -> new CandleMisakaCakeBlock(Items.YELLOW_DYE, AbstractBlock.Properties.copy(CANDLE_MISAKA_CAKE.get())));
    public static final RegistryObject<Block> LIME_CANDLE_MISAKA_CAKE = BLOCKS.register("lime_candle_misaka_cake",() -> new CandleMisakaCakeBlock(Items.LIME_DYE, AbstractBlock.Properties.copy(CANDLE_MISAKA_CAKE.get())));
    public static final RegistryObject<Block> PINK_CANDLE_MISAKA_CAKE = BLOCKS.register("pink_candle_misaka_cake",() -> new CandleMisakaCakeBlock(Items.PINK_DYE, AbstractBlock.Properties.copy(CANDLE_MISAKA_CAKE.get())));
    public static final RegistryObject<Block> GRAY_CANDLE_MISAKA_CAKE = BLOCKS.register("gray_candle_misaka_cake",() -> new CandleMisakaCakeBlock(Items.GRAY_DYE, AbstractBlock.Properties.copy(CANDLE_MISAKA_CAKE.get())));
    public static final RegistryObject<Block> LIGHT_GRAY_CANDLE_MISAKA_CAKE = BLOCKS.register("light_gray_candle_misaka_cake",() -> new CandleMisakaCakeBlock(Items.LIGHT_GRAY_DYE, AbstractBlock.Properties.copy(CANDLE_MISAKA_CAKE.get())));
    public static final RegistryObject<Block> CYAN_CANDLE_MISAKA_CAKE = BLOCKS.register("cyan_candle_misaka_cake",() -> new CandleMisakaCakeBlock(Items.CYAN_DYE, AbstractBlock.Properties.copy(CANDLE_MISAKA_CAKE.get())));
    public static final RegistryObject<Block> PURPLE_CANDLE_MISAKA_CAKE = BLOCKS.register("purple_candle_misaka_cake",() -> new CandleMisakaCakeBlock(Items.PURPLE_DYE, AbstractBlock.Properties.copy(CANDLE_MISAKA_CAKE.get())));
    public static final RegistryObject<Block> BLUE_CANDLE_MISAKA_CAKE = BLOCKS.register("blue_candle_misaka_cake",() -> new CandleMisakaCakeBlock(Items.BLUE_DYE, AbstractBlock.Properties.copy(CANDLE_MISAKA_CAKE.get())));
    public static final RegistryObject<Block> BROWN_CANDLE_MISAKA_CAKE = BLOCKS.register("brown_candle_misaka_cake",() -> new CandleMisakaCakeBlock(Items.BROWN_DYE, AbstractBlock.Properties.copy(CANDLE_MISAKA_CAKE.get())));
    public static final RegistryObject<Block> GREEN_CANDLE_MISAKA_CAKE = BLOCKS.register("green_candle_misaka_cake",() -> new CandleMisakaCakeBlock(Items.GREEN_DYE, AbstractBlock.Properties.copy(CANDLE_MISAKA_CAKE.get())));
    public static final RegistryObject<Block> RED_CANDLE_MISAKA_CAKE = BLOCKS.register("red_candle_misaka_cake",() -> new CandleMisakaCakeBlock(Items.RED_DYE, AbstractBlock.Properties.copy(CANDLE_MISAKA_CAKE.get())));
    public static final RegistryObject<Block> BLACK_CANDLE_MISAKA_CAKE = BLOCKS.register("black_candle_misaka_cake",() -> new CandleMisakaCakeBlock(Items.BLACK_DYE, AbstractBlock.Properties.copy(CANDLE_MISAKA_CAKE.get())));

    public static final RegistryObject<Block> GEKOTA_BLACK = BLOCKS.register("gekota_black",() -> new GekotaBlock(AbstractBlock.Properties.of(Material.BAMBOO).strength(0.5F).sound(SoundType.WOOD)));
    public static final RegistryObject<Block> GEKOTA_BLUE = BLOCKS.register("gekota_blue",() -> new GekotaBlock(AbstractBlock.Properties.of(Material.BAMBOO).strength(0.5F).sound(SoundType.WOOD)));
    public static final RegistryObject<Block> GEKOTA_BROWN = BLOCKS.register("gekota_brown",() -> new GekotaBlock(AbstractBlock.Properties.of(Material.BAMBOO).strength(0.5F).sound(SoundType.WOOD)));
    public static final RegistryObject<Block> GEKOTA_CYAN = BLOCKS.register("gekota_cyan",() -> new GekotaBlock(AbstractBlock.Properties.of(Material.BAMBOO).strength(0.5F).sound(SoundType.WOOD)));
    public static final RegistryObject<Block> GEKOTA_GRAY = BLOCKS.register("gekota_gray",() -> new GekotaBlock(AbstractBlock.Properties.of(Material.BAMBOO).strength(0.5F).sound(SoundType.WOOD)));
    public static final RegistryObject<Block> GEKOTA_GREEN = BLOCKS.register("gekota_green",() -> new GekotaBlock(AbstractBlock.Properties.of(Material.BAMBOO).strength(0.5F).sound(SoundType.WOOD)));
    public static final RegistryObject<Block> GEKOTA_LIGHT_BLUE = BLOCKS.register("gekota_light_blue",() -> new GekotaBlock(AbstractBlock.Properties.of(Material.BAMBOO).strength(0.5F).sound(SoundType.WOOD)));
    public static final RegistryObject<Block> GEKOTA_LIGHT_GRAY = BLOCKS.register("gekota_light_gray",() -> new GekotaBlock(AbstractBlock.Properties.of(Material.BAMBOO).strength(0.5F).sound(SoundType.WOOD)));
    public static final RegistryObject<Block> GEKOTA_LIME = BLOCKS.register("gekota_lime",() -> new GekotaBlock(AbstractBlock.Properties.of(Material.BAMBOO).strength(0.5F).sound(SoundType.WOOD)));
    public static final RegistryObject<Block> GEKOTA_MAGENTA = BLOCKS.register("gekota_magenta",() -> new GekotaBlock(AbstractBlock.Properties.of(Material.BAMBOO).strength(0.5F).sound(SoundType.WOOD)));
    public static final RegistryObject<Block> GEKOTA_ORANGE = BLOCKS.register("gekota_orange",() -> new GekotaBlock(AbstractBlock.Properties.of(Material.BAMBOO).strength(0.5F).sound(SoundType.WOOD)));
    public static final RegistryObject<Block> GEKOTA_PURPLE = BLOCKS.register("gekota_purple",() -> new GekotaBlock(AbstractBlock.Properties.of(Material.BAMBOO).strength(0.5F).sound(SoundType.WOOD)));
    public static final RegistryObject<Block> GEKOTA_RED = BLOCKS.register("gekota_red",() -> new GekotaBlock(AbstractBlock.Properties.of(Material.BAMBOO).strength(0.5F).sound(SoundType.WOOD)));
    public static final RegistryObject<Block> GEKOTA_WHITE = BLOCKS.register("gekota_white",() -> new GekotaBlock(AbstractBlock.Properties.of(Material.BAMBOO).strength(0.5F).sound(SoundType.WOOD)));
    public static final RegistryObject<Block> GEKOTA_YELLOW = BLOCKS.register("gekota_yellow",() -> new GekotaBlock(AbstractBlock.Properties.of(Material.BAMBOO).strength(0.5F).sound(SoundType.WOOD)));

    public static final RegistryObject<Block> GEKOTA_PINK = BLOCKS.register("gekota_pink",() -> new GekotaBlock(AbstractBlock.Properties.of(Material.BAMBOO).strength(0.5F).sound(SoundType.WOOD)));

    private static ToIntFunction<BlockState> candleCakeEmission(int lightlevel) {
        return (state) -> {
            return state.getValue(BlockStateProperties.LIT) ? lightlevel : 0;
        };
    }
}
